#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 10005;

int n, m;
int x[N], y[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> x[i] >> y[i];
  ll ans = 0;
  sort(y + 1, y + n + 1);
  ll m = y[(1 + n) / 2];
  rep(i, 1, n) ans += abs(m - y[i]);
  sort(x + 1, x + n + 1);
  rep(i, 1, n) x[i] -= i;
  sort(x + 1, x + n + 1);
  m = x[(1 + n) / 2];
  rep(i, 1, n) ans += abs(m - x[i]);
  cout << ans;
  return 0;
}